﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using AngleSharp.Common;
using AngleSharp.Text;
using ClassBuilder;
using ClassBuilder.Comment;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace ConsoleApp
{
    class Program
    {
        public static string LibDir = Path.GetFullPath("../../../../WUDI.ECharts");
        public static JObject Json_Option_Outline = null;
        public static JObject Json_Option = null;
        public static Download dw = new Download();

        static void Main(string[] args)
        {
            var p = new Person()
            {
                Id = 1,
                Name = "xiaoqiang",
                Age = 25
            };

            JsonSerializerSettings jsetting = new JsonSerializerSettings();
            jsetting.NullValueHandling = NullValueHandling.Ignore;
            jsetting.DefaultValueHandling = DefaultValueHandling.Ignore;
            var json = JsonConvert.SerializeObject(p, Formatting.Indented, jsetting);


            //dw.Clear();

            dw.Init();

            dw.BuildEnums();

            CSClass cls = new CSClass("EChartsOption", "WUDI.ECharts", new CSComment("图表实例的数据配置项。"));

            dw.BuildClass(dw.Json_Option_Outline, dw.GetObject(null, null), ref cls);

            dw.Clear();
        }
    }

    [JsonObject(MemberSerialization = MemberSerialization.OptIn)]
    [DataContract]
    public class Person
    {
        [DataMember]
        public long Id { get; set; }

        [DataMember]
        public string Name { get; set; }

        //[DataMember(EmitDefaultValue = false)]
        
        [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
        public int Age { get; set; } = 25;
    }
}
